window.console = window.console || (function () {
    var c = {};
    var idx = 1;
    var consolog;
    c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function () {
        if (!consolog) {
            consolog = document.getElementById("console");
        } else {
            var log = "";
            for (var i = 0; i < arguments.length; i++) {
                if (i > 0) {
                    log += " ";
                }
                log += arguments[i];
            }
            consolog.innerHTML = "<div style='border-top: 1px solid gray;'>" + idx + " : " + log + "</div>" + consolog.innerHTML;
            idx++;
        }
    };
    return c;
})();

// 数组添加indexOf事件
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function (obj, start) {
        for (var i = (start || 0), j = this.length; i < j; i++) {
            if (this[i] === obj) {
                return i;
            }
        }
        return -1;
    }
}

if (!window.location.origin) {
    window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? (':' + window.location.port) : '');
}
var origin = window.location.origin;

function getCookie(sName) {
    var aCookie = document.cookie.split("; ");
    var lastMatch = null;
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName === aCrumb[0]) {
            lastMatch = aCrumb;
        }
    }
    if (lastMatch) {
        var v = lastMatch[1];
        if (v === undefined) return v;
        return unescape(v);
    }
    return null;
}

function writeCss(url) {
    document.write('<link href="' + ROOT_PATH + url + '" rel="stylesheet" type="text/css">');
}

function writeScript(url) {
    document.write('<script src="' + ROOT_PATH + url + '" type="text/javascript"></script>');
}

writeCss("css/wui-widget.css");
writeScript("jquery-1.10.2.min.js");
writeScript("json2.js");
writeScript("md5.min.js");
writeScript("sockjs1.1.5.js");
writeScript("js/wui-widget.js");
writeScript("js/wui-bind.js");

